var app = getApp();
Page({
  data:{
    ssidname:'',
    ssidpwd:'',
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    
  },
  onReady:function(){
    // 页面渲染完成
    
  },
  onShow:function(){
    // 页面显示
    
  },
  onHide:function(){
    // 页面隐藏
    
  },
  onUnload:function(){
    // 页面关闭
    
  },
  back:function(){
      console.log("back");
      wx.navigateBack({
          delta:1
      });
  },
  confirm:function(){
    var that = this;
    console.log(this.data.ssidname);
    console.log(this.data.ssidpwd);
     wx.request({
            url: 'https://cd.tunnel.litelink.me/v1/smallapp/addSSID',
            method:'GET',
            data:{
                ssidname : that.data.ssidname,
                ssidpwd : that.data.ssidpwd,
                sn:app.globalData.SN,
                deviceid:app.globalData.deviceid
            },
            header:{
                "Content-Type":"application/json"
            },
            success: function(res) {
                if(res.data == "ok"){
                  wx.showToast({
                    title: '添加成功',
                    icon: 'success',
                    duration: 2000
                  })
                  wx.navigateBack({
                      delta:2
                  }); 
                         
                }else{
                  wx.showToast({
                    title: '添加失败',
                    icon: 'success',
                    duration: 2000
                  })
                }

            },
            
    });
    wx.showToast({
      title: '正在添加',
      icon: 'loading',
      duration: 10000
    })
    
  },
  ssidname:function(e){ 
    console.log(e.detail.value)
    this.setData({

      ssidname:e.detail.value
    })
       
  },
  ssidpwd:function(e){
    console.log(e.detail.value)
      this.setData({
      ssidpwd:e.detail.value
    })
  }
})